package com.wc.alorithm_luogu.P1077;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

/**
 * @Author congge
 * @Date 2023/9/30 21:49
 * @description [NOIP2012 普及组] 摆花
 * https://www.luogu.com.cn/problem/P1077
 */
public class Main {
    public static void main(String[] args) {
        Input scan = new Input();
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] flowersNumber = new int[n];
        for (int i = 0; i < n; i++) {
            flowersNumber[i] = scan.nextInt();
        }
        /**
         * dp[i][j] 表示 前 i+1 个 外面能摆 j 个的有多少种
         */
        int[][] dp = new int[n][m + 1];
        Arrays.sort(flowersNumber);

        int minNumber = Math.min(flowersNumber[0], m);
        for (int i = 0; i <= minNumber; i++) {
            dp[0][i] = 1;
        }

        for (int i = 1; i < n; i++) {
            dp[i][0] = 1;
        }

        for (int i = 1; i < n; i++) {
            for (int j = 1; j <= m; j++) {
                int sum = 0;
                minNumber = Math.min(j, flowersNumber[i]);
                minNumber = Math.min(minNumber, m);
                /**
                 * 遍历，自己为 0 到最大存储能一共有多少个
                 */
                for (int k = 0; k <= minNumber; k++) {
                    sum += dp[i - 1][j - k];
                    sum %= 1000007;
                }
                dp[i][j] = sum;
            }
        }

        System.out.println(dp[n - 1][m]);
    }

    /**
     * 递归会超时
     * @param flowersNumber
     * @param index
     * @param m
     * @return
     */
    public int deepScan(int[] flowersNumber, int index, int m) {
        if (m == 0) {
            return 1;
        }
        if (index == flowersNumber.length) {
            return 0;
        }
        int ans = 0;
        for (int i = 0; i <= flowersNumber[index]; i++) {
            if (i <= m) {
                ans += deepScan(flowersNumber, index + 1, m - i);
                ans %= 1000006;
            } else {
                break;
            }
        }
        return ans;
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
